/*
 * @Author: 谢子健 1075010289@qq.com
 * @Date: 2024-09-17 13:29:44
 * @LastEditors: 谢子健 1075010289@qq.com
 * @LastEditTime: 2024-09-17 13:29:54
 * @FilePath: \ilink-vue-frontend\src\stores\useStudyTreeStore.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// src/store/useStudyTreeStore.ts
import { defineStore } from "pinia";

import type { StudyTreeItem, StudyTreeState } from "@/types/course/studyTree";

export const useStudyTreeStore = defineStore("studyTreeStore", {
  state: (): StudyTreeState => ({
    clickedNodeLabel: null,
    jsonContent: null,
    studyTreeItems: [],
    totalItems: 0,
    isLoaded: false,
  }),
  actions: {
    setClickedNodeLabel(label: string) {
      this.clickedNodeLabel = label;
    },

    setJsonContent(content: any) {
      this.jsonContent = content;
    },

    setStudyTreeItems(items: StudyTreeItem[], total: number) {
      this.studyTreeItems = items;
      this.totalItems = total;
      this.isLoaded = true; // 设置为已加载
    },
  },
});
